//引入axios
import request from '@/utils/request' 
// 引入ts格式
import type {resTrademark , trademark} from './model/index'

enum API {
    trademark = "/admin/product/baseTrademark/", //get
    addTradmark = "/admin/product/baseTrademark/save", //POST 
    putTradmark = "/admin/product/baseTrademark/update", //PUT 
    clearTrademark = "/admin/product/baseTrademark/remove/" //DELETE 
}

//获取品牌接口列表
export const reqTardemarkList = (page:number,limit:number) => request.get<any,resTrademark>( API.trademark + `${page}/${limit}`)
//更新 || 修改 数据
export const reqAddTramarkPutTradmark = (data:trademark) =>{
    // 判断当前传入数据是否有id
    if(data.id){
        //如果有就是修改
        return request.put(API.putTradmark,data)
    }else{
        //没有就是新增,后台会自动添加id
        return request.post(API.addTradmark,data)
    }
}

// 通过id删除数据
export const clearTrademark = (id:number) => request.delete(API.clearTrademark + id)
